package com.yinhai.message.activemq.consumer;

import javax.jms.Destination;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.core.JmsTemplate;

import com.yinhai.message.api.vo.TMMessageVo;
/**
 * 消息消费
 * @author yanglq
 *
 */
//@Component("consumerService")
public class ConsumerService {

    private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerService.class);

//	@Resource(name="jmsTemplate")
    private JmsTemplate jmsTemplate;
     
    /**
     * 接收消息
     */
    public TMMessageVo receive(Destination destination) {
    	TMMessageVo tm = (TMMessageVo) jmsTemplate.receive(destination);
        if(LOGGER.isDebugEnabled()){
            LOGGER.debug("从队列 " + destination.toString() + " 收到了消息： \t" + tm.getMessage().getContent());
        }
        return tm;
        
    }
}
